package testJdk.commonUse.string;

import cn.hutool.core.util.NumberUtil;
import com.google.common.collect.Lists;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @version 1.0.0
 * Created by cyd on 2022-08-29 10:36:03
 * @ClassName : learn_jdk.commonUse.string.NumberToString
 * @Description : 类描述
 */
public class NumberToString {

    /**
     * 数字转字符串
     */
    @Test
    public void test() {
        Long a = 5L;
        Long b = 100L;
        String s = NumberUtil.div(a, b, 2).toString() + "%";
        System.out.println(s);
    }

    /**
     * 数组转字符串互转
     */
    @Test
    public void test02() {
        ArrayList<Long> list = Lists.newArrayList(1L, 2L);
        StringBuilder buffer = new StringBuilder();
        list.forEach(e -> {
            buffer.append(e).append(",");
        });
        System.out.println(buffer);

        List<String> list2 = Arrays.asList(buffer.toString().split(","));
        System.out.println(list2);
    }
}
